home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / n_b_v203.zip / USINGMSK.DMO < prev    next >
Text File  |  1996-07-04  |  3KB  |  56 lines

  1. $if 0
  2.     ┌──────────────────────────╖                        PowerBASIC v3.20
  3.  ┌──┤          DASoft          ╟──────────────────────┬──────────────────╖
  4.  │  ├──────────────────────────╢    Copyright 1995    │ DATE: 1995-10-01 ╟─╖
  5.  │  │ FILE NAME   USINGMSK.DMO ║          by          ╘════════════════─ ║ ║
  6.  │  │                          ║  Don Schullian, Jr.                     ║ ║
  7.  │  ╘══════════════════════════╝                                         ║ ║
  8.  │ A license is hereby granted to the holder to use this source code in  ║ ║
  9.  │ any program, commercial or otherwise,  without receiving the express  ║ ║
  10.  │ permission of the copyright holder and without paying any royalties,  ║ ║
  11.  │ as long as this code is not distributed in any compilable format.     ║ ║
  12.  │  IE: source code files, PowerBASIC Unit files, and printed listings   ║ ║
  13.  ╘═╤═════════════════════════════════════════════════════════════════════╝ ║
  14.    │                ....................................                   ║
  15.    ╘═══════════════════════════════════════════════════════════════════════╝
  16. $endif
  17.  
  18. '.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°
  19. ' ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° °
  20.  
  21. $INCLUDE "DAS-NB01.INC"
  22. COLOR 7,0
  23. CLS
  24.  
  25. ? "┌─────────────────────────────────────────────────────────────
  26. ? "│ fUsingMask$ ( Digits%, Decimals% )
  27. ? "├────────────────────────────────────────────────────────────────
  28. ? "│ This function returns a string that, when used with PRINT USING
  29. ? "│ or USING$ will produce a correctly padded numeric string.
  30. ? "│ It's use is straight forward; you need only supply the number
  31. ? "│ of places before (Digits%) and after (Decimals%) the decimal point.
  32. ? "├──────────────────────────────────────────────────────────────────────
  33. ? "│ Just a note here for our European friends and those of you wanting to
  34. ? "│ do a good job...... Some countries transpose the comma and period when
  35. ? "│ printing numbers. ie: 1,234.45 in the USA would be 1.234,45 elsewhere
  36. ? "│ and PowerBASIC has provided the wherewithal to do this quickly and
  37. ? "│ easily for any program. Have a close look at the internal variable
  38. ? "│ pbvUsingChrs. I've used it below in this example.
  39. ? "└──────────────────────────────────────────────────────────────────────────
  40.  
  41. Old$ = pbvUsingChrs              ' save this to restore pbvUsingChrs
  42. S!   = 12348.234                 ' a good number (this week)
  43. M$   = fUsingMask$( 7, 4 )       ' our using mask
  44.  
  45. PRINT "This is our mask of 7 Digits% and 4 Decimals% ";
  46. PRINT CHR$(34); M$ CHR$(34)
  47. PRINT
  48. PRINT USING M$; S!; : PRINT "  U.S.A."
  49. PRINT
  50. PRINT "Now we will print the number in European format by changing pbvUsingChrs."
  51. PRINT
  52. MID$( pbvUsingChrs, 3, 2 ) = ".,"
  53. PRINT USING M$; S!; : PRINT "  European"
  54.  
  55. pbvUsingChrs = Old$              ' leave it like you found it!
  56.